#
#  SCController.py
#  QtiSight
#
#  Created by Jonathan Saggau on 7/9/06.
#  Copyright (c) 2006 __MyCompanyName__. All rights reserved.
#

from Foundation import *
from AppKit import *
from PyObjCTools import NibClassBuilder

from scosc import controller

DEBUGGING = True

if DEBUGGING:
    import sys
    NSLog("Importing Signals")
    from PyObjCTools import Signals
    Signals.dumpStackOnFatalSignal()
    NSLog("Imported Signals")
    NSLog("Importing debugging")
    from PyObjCTools import Debugging
    Debugging.installVerboseExceptionHandler()
    #Debugging.installExceptionHandler()
    NSLog("Imported debugging")
    NSLog("System version = %s" %sys.version)

NSLog("TEST IMPORTED!!!")
NibClassBuilder.extractClasses("MainMenu.nib", bundle=NSBundle.mainBundle())

class SCController(NibClassBuilder.AutoBaseClass):
    def init(self):
        self = super(SCController, self).init()
        if not self:
            return None
        self.controller = controller.Controller(('127.0.0.1', 57110),verbose=True, spew=True)
        # default port and IP for now
        
        NSLog(u"SCController init python")
        NSLog(u"SELF = ")
        NSLog(self)
        return self
        
    def sendMsg_(self, msg):
        #NSLog(u"SCController sendMsg_ python")
        #NSLog(msg)
        #super(SCController, self).sendMsg_(msg)
        self.controller.listSendMsg(msg)
        
    def log(self):
        NSLog(u"TESTING 123 ---- SCController log python")
        super(SCController, self).log()